package com.edu.test;

import com.edu.bean.User;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

/**
 *  spring管理的bean 如何获取 beanId 和 容器
 */
public class MyTest02 {

    ClassPathXmlApplicationContext context ;

    @Before
    public void init(){

        context = new ClassPathXmlApplicationContext("spring-ioc.xml");

    }

    @Test
    public void test01(){


        User user = context.getBean(User.class);
//        System.out.println("从容器中获取了bean");
//        System.out.println(user);
        user.sayHi();
        context.close();

    }
}
